﻿/*======================================
作者：洞庭夕照
创建：2017.10.30
网站：www.ninesky.cn
      mzwhj.cnblogs.com
支持：bbs.ninesky.cn
代码：git.oschina.net/ninesky/Ninesky
版本：v1.0.0.0
======================================*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Ninesky.IService;
using Ninesky.Models;

namespace Ninesky.MVC.ViewComponents
{
    public class CategoryNavViewComponent : ViewComponent
    {
        private ICategoryService _categoryService { get; set; }

        public CategoryNavViewComponent(ICategoryService categoryService)
        {
            _categoryService = categoryService;
        }
        public async Task<IViewComponentResult> InvokeAsync()
        {
            var categories = await _categoryService.FindListAsync<int>(0,c => c.ParentId == 0, c=>c.Order, true);
            return View(categories);
        }
    }
}